export const ERROR_MESSAGES = {
    EMAIL_REQUIRED: '请输入邮箱',
    INVALID_EMAIL: '请输入有效的邮箱地址',
    PASSWORD_REQUIRED: '请输入密码',
    PASSWORD_TOO_SHORT: '密码长度至少为8位',
    NAME_REQUIRED: '请输入姓名',
    CONFIRM_PASSWORD_REQUIRED: '请确认密码',
    PASSWORD_MISMATCH: '两次输入的密码不一致',
    AGREE_TERMS_REQUIRED: '请同意服务条款和隐私政策'
};

export function validateLoginForm(form) {
    const errors = {};
    if (!form.email) {
        errors.email = ERROR_MESSAGES.EMAIL_REQUIRED;
    } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email)) {
        errors.email = ERROR_MESSAGES.INVALID_EMAIL;
    }
    if (!form.password) {
        errors.password = ERROR_MESSAGES.PASSWORD_REQUIRED;
    } else if (form.password.length < 8) {
        errors.password = ERROR_MESSAGES.PASSWORD_TOO_SHORT;
    }
    return errors;
}

export function validateRegisterForm(form) {
    const errors = {};
    if (!form.name) {
        errors.name = ERROR_MESSAGES.NAME_REQUIRED;
    }
    if (!form.email) {
        errors.email = ERROR_MESSAGES.EMAIL_REQUIRED;
    } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.email)) {
        errors.email = ERROR_MESSAGES.INVALID_EMAIL;
    }
    if (!form.password) {
        errors.password = ERROR_MESSAGES.PASSWORD_REQUIRED;
    } else if (form.password.length < 8) {
        errors.password = ERROR_MESSAGES.PASSWORD_TOO_SHORT;
    }
    if (!form.confirmPassword) {
        errors.confirmPassword = ERROR_MESSAGES.CONFIRM_PASSWORD_REQUIRED;
    } else if (form.confirmPassword !== form.password) {
        errors.confirmPassword = ERROR_MESSAGES.PASSWORD_MISMATCH;
    }
    return errors;
} 